package cn.kgc.springcloud.hystrix.controller;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: mosin
 * @version: v1.0  2022/8/19
 */
@RestController
@RequestMapping("hystrix")
public class HystrixController {

    @RequestMapping("t1")
    @HystrixCommand(fallbackMethod ="test1FallbackMethod")
    public String test1(Integer number){

        if(number<2){
            throw new  RuntimeException("参数有误");
        }
        return "Hystrix controller ok ";
    }

    // 创建服务熔断之后快速的响应方法
    public  String  test1FallbackMethod(Integer number){
        return "服务被熔断,请稍后再试!!"+number;
    }

}
